let balls = []; //双色球数组
let redBallCount = 6; //红球个数

//红球取法，从1-33里面随机选6个不重复的数字
while (balls.length < redBallCount) {
    let num = getRandom(1, 33);
    if (!contains(num, balls)) {
        balls.push(num);
    }
}
console.log("红球是");
console.log(balls.toString());

//冒泡排序
for (let i = 0; i < balls.length; i++) {
    for (let j = i + 1; j < balls.length; j++) {
        if (balls[i] > balls[j]) {
            let temp = balls[j];
            balls[j] = balls[i];
            balls[i] = temp;
        }
    }
}
console.log("红球排序后是");
console.log(balls.toString());

//取蓝球
let blueBall = getRandom(1, 16);
balls.push(blueBall);

console.log("双色球是");
console.log(balls.toString());

//数组是否包含元素
function contains(element, arr) {
    for (let i = 0; i < arr.length; i++) {
        if (element === arr[i]) {
            return true;
        }
    }
    return false;
}

//[min, max]取随机数
function getRandom(min, max) {
    return Math.floor(Math.random() * (max - min + 1)) + min;
}